Skip to content

fix(tui): stop completion mangling column names that need quoting (T1) - #57

Merged
TimelordUK merged 1 commit into
mainfrom
feat/tui-completion-quoted-columns
Aug 30, 2026
Merged

fix(tui): stop completion mangling column names that need quoting (T1)#57
TimelordUK merged 1 commit into
mainfrom
feat/tui-completion-quoted-columns

Conversation

@TimelordUK

Copy link
Copy Markdown
Owner

Completion had two independent backward scanners from the cursor. The parser decided what to suggest; extract_partial_word_at_cursor in text_operations.rs independently decided what span to replace. They disagreed whenever quotes or dots were involved.

On data/countries.csv (name.common, idd.root, translations.ara.official):

SELECT name. offered Contains('') instead of the columns
SELECT name.com offered nothing at all
SELECT "na produced SELECT name.common" (quote eaten)
SELECT na produced SELECT "name.commonname.official"

So every column that has to be quoted was effectively unreachable by completion, and cycling corrupted the buffer.

Introduce src/sql/completion_token.rs: one quote- and dot-aware scanner both halves share, handling an open quote, a cursor just past a closing quote, and a bare identifier where dots are part of the name. Add ParseResult::replace_start so the parser hands the editor the byte span to splice over instead of the editor guessing, threaded through HybridResult and CompletionState so it survives Tab cycling.

complete_dotted_column resolves dotted text that prefixes a real column; text matching no column (capital.Con, 1.5, t.name) falls through to the existing method-call handling unchanged.

Also replaces ~55 lines of tangled quote-matching in the suggestion filter with a single unquoted comparison, and deletes the now-unused extract_partial_word_at_cursor - leaving a superseded duplicate scanner in place is how this regresses.

Adds docs/TUI_FEATURES.md, a T-numbered book of work for the interactive editor alongside the P (parity) and R (refactoring) logs. The TUI has no equivalent of the parity harness, so its defects only surface in use; T2-T6 record what this fix uncovered, including that get_property_type is still a hardcoded list of trade-desk column names.

Tests: tests/dotted_column_completion.rs (12) covers both halves - what is suggested and what the buffer ends up containing - plus 9 unit tests for the scanner. Full suite green, no new clippy warnings.

Claude-Session: https://claude.ai/code/session_0152wRProARq2WGPss4698iY

Completion had two independent backward scanners from the cursor. The
parser decided *what* to suggest; extract_partial_word_at_cursor in
text_operations.rs independently decided *what span to replace*. They
disagreed whenever quotes or dots were involved.

On data/countries.csv (name.common, idd.root, translations.ara.official):

  SELECT name.<tab>     offered Contains('') instead of the columns
  SELECT name.com<tab>  offered nothing at all
  SELECT "na<tab>       produced SELECT name.common"  (quote eaten)
  SELECT na<tab><tab>   produced SELECT "name.commonname.official"

So every column that has to be quoted was effectively unreachable by
completion, and cycling corrupted the buffer.

Introduce src/sql/completion_token.rs: one quote- and dot-aware scanner
both halves share, handling an open quote, a cursor just past a closing
quote, and a bare identifier where dots are part of the name. Add
ParseResult::replace_start so the parser hands the editor the byte span
to splice over instead of the editor guessing, threaded through
HybridResult and CompletionState so it survives Tab cycling.

complete_dotted_column resolves dotted text that prefixes a real column;
text matching no column (capital.Con, 1.5, t.name) falls through to the
existing method-call handling unchanged.

Also replaces ~55 lines of tangled quote-matching in the suggestion
filter with a single unquoted comparison, and deletes the now-unused
extract_partial_word_at_cursor - leaving a superseded duplicate scanner
in place is how this regresses.

Adds docs/TUI_FEATURES.md, a T-numbered book of work for the interactive
editor alongside the P (parity) and R (refactoring) logs. The TUI has no
equivalent of the parity harness, so its defects only surface in use;
T2-T6 record what this fix uncovered, including that get_property_type
is still a hardcoded list of trade-desk column names.

Tests: tests/dotted_column_completion.rs (12) covers both halves - what
is suggested and what the buffer ends up containing - plus 9 unit tests
for the scanner. Full suite green, no new clippy warnings.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0152wRProARq2WGPss4698iY
@TimelordUK
TimelordUK merged commit 2fedbf8 into main Aug 30, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant